<?php
define('DS', DIRECTORY_SEPARATOR);
define('DOC_ROOT', dirname(__FILE__) . DS);
define('CLASS_PATH', DOC_ROOT . 'class' . DS);
define('INCLUDE_PATH', DOC_ROOT . 'include' . DS);
define('LIBRARY_PATH', DOC_ROOT . 'libs' . DS);

session_start();

/**
 * 全局环境设置.
 * -----------------------------------------
 */
date_default_timezone_set('Asia/Chongqing');
register_shutdown_function('OnProcessEnd');

include (INCLUDE_PATH . 'config.inc.php');
include (LIBRARY_PATH . 'LeeNT_MySql.class.php');
include (CLASS_PATH   . 'BasePage.class.php');
include (CLASS_PATH   . 'IController.class.php');

$cfgs['skin'] = 'petpaws';

/**
 * 实例化 LeeNT_MySql 数据操作对象.
 * -----------------------------------------
 */
$db = &new LeeNT_MySql(array(
	'host'    => $cfgs['db_host'],
	'dbname'  => $cfgs['db_name'],
	'user'    => $cfgs['db_user'],
	'pass'    => $cfgs['db_pass'],
	'charset' => $cfgs['db_charset']
));

/**
 * 导入 class 类文件。
 *
 * @param string $class
 */
function using($class) {
	$class = explode('.', $class);
	
	include (CLASS_PATH . strtolower($class[0]) . DS . ucwords($class[0]) . '_' . ucwords($class[1]) . 'Controller.class.php');
}

/**
 * 资源释放。
 *
 */
function OnProcessEnd() {
	global $db;
	
	$db->close();
}